<?php

class Silk_Tms_Block_Adminhtml_Shippingorder_Grid extends Mage_Adminhtml_Block_Widget_Grid
{
    public function __construct()
    {
        parent::__construct();
        $this->setId("ShippingorderGrid");
        $this->setDefaultSort("created_at");
        $this->setDefaultDir("DESC");
        $this->setSaveParametersInSession(true);
    }
    protected function _prepareCollection()
    {
        
        $collection = Mage::getModel("tms/shipping_order")->getCollection();
        $collection->addFieldToFilter("shipping_id","0");
        $websiteId = Mage::getSingleton('admin/session')->getUser()->getWebsiteId();
        if($websiteId){
            $website = Mage::getModel('core/website')->load($websiteId);
            $storeId = $website->getDefaultStore()->getId();
            $collection->addFieldToFilter("store_id",$storeId);
        }
        $this->setCollection($collection);
        return parent::_prepareCollection();
    }
    protected function _prepareColumns()
    {
            $this->addColumn("id", array(
            "header" => Mage::helper("tms")->__("ID"),
            "align" =>"right",
            "width" => "100px",
            "type" => "number",
            "index" => "id",
            ));
            $this->addColumn("increment_id", array(
            "header" => Mage::helper("tms")->__("订单号"),
            "index" => "increment_id",
            'align' => 'center',
            ));
            $this->addColumn("customer_name", array(
            "header" => Mage::helper("tms")->__("收货人"),
            "index" => "customer_name",
            'align' => 'center',
            ));
            $this->addColumn("customer_store_name", array(
            "header" => Mage::helper("tms")->__("店铺名称"),
            "index" => "customer_store_name",
            'align' => 'center',
            ));
            $this->addColumn("customer_phone", array(
            "header" => Mage::helper("tms")->__("收货人电话"),
            "index" => "customer_phone",
            'align' => 'center',
            ));
            $this->addColumn("place_order_time", array(
            "header" => Mage::helper("tms")->__("下单时间"),
            "index" => "place_order_time",
            'align' => 'center',
            ));
            $this->addColumn("grand_total", array(
            "header" => Mage::helper("tms")->__("订单总额"),
            "index" => "grand_total",
            'align' => 'center',
            ));
            $this->addColumn("customer_address", array(
            "header" => Mage::helper("tms")->__("收货地址"),
            "index" => "customer_address",
            'align' => 'center',
            ));
            if(Mage::getSingleton('admin/session')->isAllowed('sales/order/actions/addshipping'))
            {
                $this->addColumn('action',
                    array(
                        'header'   =>   Mage::helper('tms')->__('Action'),
                        'type'     =>   'action',
                        'getter'   =>   'getOrderId',
                        'align' => 'center',
                        'actions'  =>   array(
                            array(
                                'caption' =>  Mage::helper('tms')->__('选择运单'),
                                'url'     => array(
                                		//add by wanglin  异常区订单加入运单只显示分拣完成
                                		// 'base'=>"adminhtml/sales_order/addshipping",
                                    'base'=>"adminhtml/sales_order/addshipping/canshu/1",
                                ),
                                'field'   =>  'order_ids'
                            ),
                         ),
                        'filter'      =>  false,
                        'sortable'    =>  false,
                        'width' => '100px',
                    )
                );
            }
            return parent::_prepareColumns();
    }
  /*  protected function _prepareMassaction()
    {
        $this->setMassactionIdField('order_id');
        $this->getMassactionBlock()->setFormFieldName('order_ids');
        $this->getMassactionBlock()->setUseSelectAll(false);
        if(Mage::getSingleton('admin/session')->isAllowed('sales/order/actions/addshipping'))
        {
            $this->getMassactionBlock()->addItem('shipping_update', array(
                'label'=> Mage::helper('sales')->__('加入运单'),
                'url'  => $this->getUrl('adminhtml/sales_order/addshipping'),
            ));
        }
    }*/
}